'use strict';

import * as actions from '../../actions/zhekou_limit_step1';

// 对页面prop 数据进行管理
const initialState = {
		  creating: false,
		  error:false,
		  loginError:false,
		  message:"",
		  zType:"decreaseAmount",
		  setItems:[]
};
const defaultAction = {
  type: 'doNothing'
};

export default function index(state = initialState, action = defaultAction) {
  switch (action.type) {
	  case actions.CREAT_ZHEKOU_START:
	      return Object.assign({}, state, {
	        creating:true,
	        error:false,
	        loginError:false,
			  actionDone:false
	      });
	  break;
    case actions.CREAT_ZHEKOU_DONE:
	      return Object.assign({}, state, {
	        creating:false,
	        error:false,
	        loginError:false,
			  data:action.data,
	        activityId:action.activityId,
		     actionDone:action.actionDone
	      });
	  break;
    case actions.CREAT_ZHEKOU_ERR:
	      return Object.assign({}, state, {
	        creating:false,
			error:true,
			loginError:action.loginFalse,
			message:action.message
	      });
	  break;
    case actions.CLOSE_DIALOG:
        return Object.assign({}, state, {
  		error:action.visible,
          loginError:false
        });
  	  break;
    case actions.CREATE_NEW:
    	return Object.assign({}, state, {
    		activityId:false,
    		setItems:[]
	      });
    	break;
    case actions.ADD_ITEM_TO_ACTIVE:
    	state.setItems[action.newItemSet.num_iid]=action.newItemSet;
        return Object.assign({}, state, {
  		creating:false,
  		error:false,
  		loginError:false,
  		editItemIid:action.newItemSet.num_iid
        });
    default:
      return state;
  }
}



